<template>
  <div>
    <el-card>
      <div slot="header" style="font-size: 20px; font-weight: 600">
        日志管理
      </div>
      <div style="font-size: 16px; margin-bottom: 10px">
        <span style="font-weight: 600">日志管理 </span>
        <i class="el-icon-arrow-right"></i>
        <span class="mybreadcrumb" @click="router.push('/loggerManagent')"
          >日志类型
        </span>
      </div>
      <el-table
        :data="loggers"
        v-loading="tableLoading"
        element-loading-text="正在加载日志文件数据..."
      >
        <el-table-column
          width="280px"
          align="center"
          label="文件名"
          prop="name"
        >
          <template slot-scope="scope">
            <div style="text-align: center" v-if="scope.row.isDir">
              <el-button
                plain
                style="
                  border:none 
                  width: 100%;
                  margin-left: 90px;
                  display: flex;
                  justify-content: flex-start;
                "
                @click="toLoggerList(scope.row.name)"
              >
                <div style="display: flex; align-items: center">
                  <span
                    class="iconfont icon-wenjianjia"
                    style="font-size: 40px; color: #409eff"
                    >&nbsp;</span
                  >
                  <span>{{ scope.row.name }}</span>
                </div>
              </el-button>
            </div>
            <div style="text-align: center" v-else>
              <el-button
                plain
                style="
                  border:none 
                  width: 100%;
                  margin-left: 90px;
                  display: flex;
                  justify-content: flex-start;
                "
                @click="getNohup(scope.row.name)"
              >
                <div style="display: flex; align-items: center">
                  <span
                    class="iconfont icon-rizhiguanli"
                    style="font-size: 40px; color: #409eff"
                    >&nbsp;</span
                  >
                  <span>{{ scope.row.name }}</span>
                </div>
              </el-button>
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" label="描述" prop="discription">
          <template slot-scope="scope">
            <div>
              <span>{{ scope.row.discription }} </span>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loggers: [
        { name: "debug", discription: "调试日志", isDir: true },
        { name: "error", discription: "错误日志", isDir: true },
        { name: "info", discription: "普通日志", isDir: true },
        { name: "warnning", discription: "警告日志", isDir: true },
        { name: "nohup.out", discription: "运行信息", isDir: false }
      ],
      tableLoading: false,
      loggerInfo: "666",
      pathInfo: { path: "/loggerList", params: { data1: "111", data2: "222" } },
      loggerList: { warn: [], info: [], debug: [], error: [] }
    };
  },
  async created() {
    const { data: res } = await this.$http.get("/smtpmail/log/nameList");
    console.log(res);
    if (res.code === 20000) {
      this.loggerList.debug = res.data.debug;
      this.loggerList.error = res.data.error;
      this.loggerList.info = res.data.info;
      this.loggerList.warn = res.data.warn;
      console.log(this.loggerList);
    }
  },
  methods: {
    toLoggerList(type) {
      if (type == "warnning") type = "warn";
      window.sessionStorage.setItem("loggerType", type);
      window.sessionStorage.setItem("loggers", JSON.stringify(this.loggerList));
      this.$router.push("/loggerList");
    },
   async getNohup() {
     window.location.href="http://124.221.41.252:8080/smtpmail/log/nohup.out"
    }
  }
};
</script>


<style lang="less" scoped>
.mybreadcrumb:hover {
  cursor: pointer;
  color: #409eff;
}
</style>>

